<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            position: relative;
            width: 800px;
            height: 500px;
            background-color: blue;
            /*  transform:translateX(50%); -------移动盒子自身宽度的百分之50*/
            /* transform: translateX(50%); */
        }
        
        img {
            position: absolute;
            top: 50%;
            left: 50%;

            /* 定位让盒子居中-外边距回调方法 */
            /* margin-left: -166px;
            margin-top: -143px; */

             /* 定位让盒子居中-2d转换回调方法 */
             transform: translate(-50%,-50%);

        }
        span {
            background-color: red;
            /* transform: translate(200px,200px);-----对于行内元素无效 */
            transform: translate(200px,200px);
        }
    </style>
</head>
<body>
    <div>
        <img src="images\img.png" alt="">
    </div>
    <span>11</span>
</body>
</html>